<h1>Users</h1>
<!--<div id="infoMessage"><?php echo $message;?></div>-->

<table class="table table-striped table-bordered" width="100%" id="example">
	<thead>
    <tr>
		<th>First Name</th>
		<th>Last Name</th>
		<th>Email</th>
		<th>Role</th>
        <th>Department</th>
        <th>User Type</th>
		<th>Status</th>
		<th>Action</th>
	</tr>
    </thead>
	<?php foreach ($users as $user):?>
		<tr>
			<td><?php echo $user->first_name;?></td>
			<td><?php echo $user->last_name;?></td>
			<td><?php echo $user->email;?></td>
			<td>
				<?php foreach ($user->groups as $group):?>
					<?= $group->name?><br />
                <?php endforeach?>
			</td>
            <td>
            <?php foreach ($user->department as $user_type):?>
					<?=$user_type->name?><br />
                <?php endforeach?>
            </td>
            <td>            
           <?php foreach ($user->user_type as $user_type):?>
					<?=$user_type->name ?><br />
                <?php endforeach?>    
           </td>            
			<td><?php echo ($user->active) ? anchor("auth/deactivate/".$user->id, 'Active') : anchor("auth/activate/". $user->id, 'Inactive');?></td>
			<td><?php echo anchor("auth/edit_user/".$user->id, 'Edit') ;?></td>
		</tr>
	<?php endforeach;?>
    <tfoot>
    <tr>
		<th>First Name</th>
		<th>Last Name</th>
		<th>Email</th>
		<th>Role</th>
        <th>Department</th>
        <th>User Type</th>
		<th>Status</th>
		<th>Action</th>
	</tr>
    </tfoot>
</table>

<!--<p><a href="<?php echo site_url('auth/create_user');?>">Create a new user</a> | <a href="<?php echo site_url('auth/create_group');?>">Create a new group</a>
<a href="<?php echo site_url('auth/logout');?>">Logout</a>
</p>-->
